<template>
	<Layout class="p-5 bg-white">
		<Form class="p-5" :model="house" :label-width="80">
			<FormItem class="w-50" label="房屋描述">
				<Input v-model="house.des" />
			</FormItem>
			<FormItem class="w-50" label="户型">
				<Input v-model="house.roomCount" />
			</FormItem>
			<FormItem class="w-50" label="省">
				<Input v-model="house.provienceId" />
			</FormItem>
			<FormItem class="w-50" label="市">
				<Input v-model="house.cityId" />
			</FormItem>
			<FormItem class="w-50" label="区">
				<Input v-model="house.reignId" />
			</FormItem>
			<FormItem class="w-50" label="小区">
				<Input v-model="house.xiaoqu" placeholder="请输入小区"></Input>
			</FormItem>
			<FormItem class="w-50" label="片区">
				<Input v-model="house.pianqu" placeholder="请输入片区"></Input>
			</FormItem>
			<FormItem class="w-50" label="楼层">
				<Select v-model="house.louceng" style="width:150px">
				        <Option  v-for="item in floors" :key="item.value" :value="item.value">{{ item.label }}</Option>
				</Select>
			</FormItem>
			<FormItem class="w-50" label="装修">
				<Select v-model="house.zhuangxiu" style="width:150px">
				        <Option  v-for="item in repairs" :key="item.value" :value="item.value">{{ item.label }}</Option>
				</Select>
			</FormItem>
			<FormItem class="w-50" label="朝向">
				<Select v-model="house.chaoxiang" style="width:150px">
				        <Option  v-for="item in faces" :key="item.value" :value="item.value">{{ item.label }}</Option>
				</Select>
			</FormItem>
			<FormItem class="w-50" label="电梯">
				<Select v-model="house.dianti" style="width:150px">
				        <Option  v-for="item in lifts" :key="item.value" :value="item.value">{{ item.label }}</Option>
				</Select>
			</FormItem>
			<FormItem class="w-50" label="图片地址">
				<Input v-model="house.imgUrl" />
			</FormItem>
			
			
			<FormItem class="text-right">
				<Button @click="submit" type="primary">提交</Button>
				<Button @click="cancel" class="ml-2">取消</Button>
			</FormItem>
		</Form>
	</Layout>
</template>
<script>
	export default {
		data() {
			return {
				house: {
					houseId: 0,
					des: "",
					provienceId: "",
					cityId: "",
					reignId: "",
					detailLocation: "",
					hallCount: "",
					roomCount: "",
					area: "",
					imgUrl: "",
					ct: "",
					ut: ""
				},
				roomCounts:[
						{value:1,label:'一室'},
						{value:2,label:'二室'},
						{value:3,label:'三室'},
						{value:4,label:'四室'},
						{value:5,label:'五室以上'},
						{value:6,label:'上跃'},
						{value:7,label:'下跃'},
						{value:8,label:'别墅'}
					],
					floors:[
						{value:'高',label:'高'},
						{value:'中',label:'中'},
						{value:'低',label:'低'},
						{value:'多层',label:'多层'},
						{value:'小高层',label:'小高层'},
						{value:'高层',label:'高层'},
					],
					faces:[
						{value:'南北',label:'南北'},
						{value:'东西',label:'东西'},
						{value:'其他',label:'其他'}
					],
					repairs:[
						{value:'清水',label:'清水'},
						{value:'简装',label:'简装'},
						{value:'精装',label:'精装'},
						{value:'豪装',label:'豪装'}
					],
					lifts:[
						{value:1,label:'有'},
						{value:2,label:'无'}
					],
			}
		},
		methods: {
			cancel: function() {
				this.$tabs.close();
			},
			submit: function() {
				let self = this;
				let houses = [];
				for (let index in this.$data.houses) {
					let houseItem = this.$data.house[index];
					houses.push(houseItem.houseId);
				}
				self.house.houses = JSON.stringify(houses);
				this.http.put({
					url: "/house/info",
					param: self.house,
				}).then(() => {
					self.message.info("修改成功");
					self.$tabs.close();
					this.$router.push({
						name: "house",
						params: {}
					});
				});
			},
			init: function() {
				let self = this;
				this.http.get({
					url: "/house/info",
					param: {
						houseId: this.$data.house.houseId
					}
				}).then(data => {
					self.$data.house = data;
				});
			},
		},
		created: function() {
			this.$data.house.houseId = this.$route.params.houseId;
			this.init();
		},
	}
</script>
<style>
</style>
